<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/comm/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="${ctx}/img/favicon.ico">

    <link rel="stylesheet" href="${ctx}/layui/css/layui.css">
    <link rel="stylesheet" href="${ctx}/css/global.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/personal.css" media="all">
    <link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_9h680jcse4620529.css">


    <script src="${ctx}/layui/layui.js"></script>
<body>
<div class="larry-grid larryTheme-A">
    <div class="larry-personal">
        <div class="layui-tab">
            <blockquote class="layui-elem-quote mylog-info-tit">
                <div class="layui-inline">
                    <form class="layui-form" id="userSearchForm">
                        <div class="layui-input-inline" style="width:145px;">
                            <input type="text" name="searchContent" value="" placeholder="请输入关键字"
                                   class="layui-input search_input">
                        </div>
                        <a class="layui-btn userSearchList_btn" lay-submit lay-filter="userSearchFilter"><i
                                class="layui-icon larry-icon larry-chaxun7"></i>查询</a>
                    </form>
                </div>

            </blockquote>
            <div class="larry-separate"></div>
            <!-- 用户列表 -->
            <div class="layui-tab-item layui-field-box layui-show">
                <div class="layui-form">
                    <table class="layui-table" lay-even="" lay-skin="row">
                        <thead>
                        <tr>
                            <th><input name="" lay-skin="primary" lay-filter="allChoose" type="checkbox"></th>
                            <th>序号</th>
                            <th>船号</th>
                            <th>凭证</th>
                            <th>提交时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="userTbody"></tbody>
                    </table>
                </div>
                <div class="larry-table-page clearfix" id="userPage"></div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    layui.config({
        base: "${ctx}/js/"
    }).use(['form', 'laypage', 'layer', 'common'], function () {
        var $ = layui.jquery,
            form = layui.form(),
            laypage = layui.laypage,
            layer = layui.layer,
            common = layui.common;


        /**加载用户列表信息*/
        payPageList(1);

        /**全选*/
        form.on('checkbox(allChoose)', function (data) {
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        /**拒绝原因页面*/
        $("body").on("click", ".examine", function () {

            var payId = $(this).attr("data-id");
            var shipNo = $(this).attr("data-shipno")
            var url = "${ctx}/main/rejectPage?examineType=1&optType=1&examineId=" + payId + "&shipNo=" + shipNo;
            common.cmsLayOpen('编辑用户', url, '550px', '265px');

        });


//        /**同意审核*/
        $("body").on("click", ".payaccept", function () {
            var payId = $(this).attr("data-id");
            var shipNo = $(this).attr("data-shipno")
            var acceptType = $(this).attr("data-optType")
            var examineType = $(this).attr("data-examineType")
            var data = {"examineId": payId, "shipNo": shipNo, "optType": acceptType, "examineType": examineType};
            layer.confirm("确认提示", {
                title: "确认审核通过吗",
                resize: false,
                btn: ['确定', '取消'],
                btnAlign: 'c',
                anim: 1,
                icon: 3
            }, function () {
                $.ajax({
                    url: "/rest/ma/examine",
                    type: 'post',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: JSON.stringify(data),
                    async: false,
                    success: function (data) {
                        if (data.resultCode == 0) {
                            top.layer.msg(data.resultMsg, {icon: 6});
                            location.reload();
                        } else {
                            top.layer.msg(data.resultMsg, {icon: 5});
                        }
                    }, error: function (data) {

                    }
                });

            }, function () {

            })

        });


        //
        /**查询*/
        $(".userSearchList_btn").click(function () {
            //监听提交
            form.on('submit(userSearchFilter)', function (data) {
                userPageList(1, data.field.searchTerm, data.field.searchContent);
            });

        });
        /**加载缴费信息**/
        function payPageList(curr, searchTerm, searchContent) {
            var pageLoading = layer.load(2);
            $.ajax({
                url: '${ctx}/rest/pay/queryAll',
                type: 'post',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: {
                    page: curr || 1,   //当前页
                    rows: 7,          //每页显示7条数据
                    searchTerm: searchTerm,
                    searchContent: searchContent
                },
                success: function (data) {
                    if (data != "") {
                        $("#userTbody").text('');//先清空原先内容
                        if (data.resultCode == 0) {
                            for (var index = 0; index < data.obj.length; index++) {
                                //操作按钮
                                var opt = '<div class="layui-btn-group">';
                                opt += '<a class="layui-btn layui-btn-mini layui-btn-warm examine" data-optType=1  data-id="' + data.obj[index].payId + '" data-shipno="' + data.obj[index].shipNo + '"><i class="layui-icon larry-icon larry-bianji2"></i> 拒绝</a>';
                                opt += '<a class="layui-btn layui-btn-mini  payaccept" data-optType=2 data-id="' + data.obj[index].payId + '"  data-shipno="' + data.obj[index].shipNo + '" data-examineType=1><i class="layui-icon larry-icon larry-jiaoseguanli3"></i>同意</a>';
                                opt += '</div>';
                                //组装table
                                $("#userTbody").append(
                                    '<tr>' +
                                    '<td><input name="userIdCK" lay-skin="primary" type="checkbox" " value="' + data.obj[index].payId + '"></td>' +
                                    '<td title="' + objNull(data.obj[index].payId) + '">' + objNull(data.obj[index].payId) + '</td>' +
                                    '<td title="' + objNull(data.obj[index].shipNo) + '">' + objNull(data.obj[index].shipNo) + '</td>' +
                                    '<td title="' + objNull(data.obj[index].vouCherUrl) + '"><a href="#"><img src="' + objNull(data.obj[index].vouCherUrl) + '"/></a></td>' +
                                    '<td title="' + objNull(data.obj[index].commitTime) + '">' + objNull(data.obj[index].commitTime) + '</td>' +
                                    '<td>' + opt + '</td>' +
                                    '</tr>'
                                );

                            }
                        } else {
                            layer.msg(data.resultMsg);
                        }
                        //重新渲染form
                        form.render();
                        layer.close(pageLoading);
                    }
                }

            });
        };
    });
    /**undefined 值 过滤*/
    function objNull(obj) {
        if (typeof(obj) == "undefined" || obj == null) {
            return "";
        }
        return obj;
    }

</script>

</body>
</html>